package xyz.jangle.jdbc.test;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
 * 时区测试
 * @author Administrator
 *
 */
public class JdbcMetaData {

	public static void main(String[] args) {
		
//		String url = "jdbc:mysql://127.0.0.1:3306/jangle_test?characterEncoding=UTF8&serverTimezone=UTC";
		String url = "jdbc:mysql://127.0.0.1:3306/jangle_test?characterEncoding=UTF8&serverTimezone=Asia/Shanghai";
		String user = "root";
		String password = "111111";
      
      try(Connection con = DriverManager.getConnection(url, user, password)){
    	  DatabaseMetaData metaData = con.getMetaData();
    	  ResultSet columns = metaData.getColumns(null, null, "demo", null);
    	  while(columns.next()) {
    		  System.out.print(columns.getString(1)+" ");
    		  System.out.print(columns.getString(2)+" ");
    		  System.out.print(columns.getString(3)+" ");
    		  System.out.println(columns.getString(4));
//    		  System.out.println(columns.getString("column_name"));
    	  }
    	  
      } catch (SQLException e) {
		e.printStackTrace();
      }

	}

}
